<?php

function creatrss2($itemss){

	if(!isset($itemss) || empty($itemss) || !is_array($itemss))
			return false;

	header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
	$more = 1;

	echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';

?>

<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
	<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
	<link><?php bloginfo_rss('url') ?></link>
	<description><?php bloginfo_rss("description") ?></description>
	<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
	<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
	<language><?php echo get_option('rss_language'); ?></language>

	<?php foreach($itemss as $items) : ?>
	<?php foreach($items as $item) : ?>
	<item>
		<title><?php echo $item['title']; ?></title>
		<link><?php echo $item['link']; ?></link>
		<comments><?php echo $item['comments']; ?></comments>
		<pubDate><?php echo $item['pubdate']; ?></pubDate>
		<dc:creator><?php echo empty($item['dc:creator']) ? $item['author'] : $item['dc:creator']; ?></dc:creator>
		<category><?php echo $item['category']; ?></category>

		<guid isPermaLink="false"><?php echo $item['guid']; ?></guid>
		<description><![CDATA[<?php echo $item['description']; ?>]]></description>
		<content:encoded><![CDATA[<?php echo $item['content:encoded']; ?>]]></content:encoded>
		<wfw:commentRss><?php echo htmlentities($item['wfw:commentrss']); ?></wfw:commentRss>
	</item>
	<?php endforeach; endforeach; ?>
</channel>
</rss>

<?php
	exit;
}

?>